package com.x.part3_代码块;

/**
 * ClassName: Person
 * Package: IntelliJ IDEA
 * Description:
 * Written by HanXu
 * Create 2024.03.02 20:16
 */
public class PersonTest{
    public static void main(String[] args) {
        Person p1 = new Person();
        System.out.println(p1.toString());

    }
}

class Person {

    String name;
    int age;
    public Person(){

    }

    public void eat(){
        System.out.println("eat");
    }

    @Override
    public String toString() {
        return "Person{" +
                "age=" + age +
                '}';
    }

    {
        System.out.println("非静态代码块1");
        age=1;
    }

    static {
        System.out.println("静态代码块1");
        System.out.println("类开始加载");
    }
}
